package com.zuul.main;

import com.zuul.conf.FilterConfiguration;
import com.zuul.filter.AccessFilter;
import com.zuul.filter.exception.ThrowExceptionFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;

//@ComponentScan(basePackages = "com.zuul.retry")
@EnableZuulProxy
@SpringBootApplication
public class ZuulApplication {

    public static void main(String[] args){
        SpringApplication.run(ZuulApplication.class,args);
    }


    /**
     * 流程过滤
     * */
    @Bean
    public AccessFilter accessFilter(){
        return new AccessFilter();
    }

    /**
     * 异常处理
     * */
//    @Bean
//    public ThrowExceptionFilter throwExceptionFilter(){
//        return new ThrowExceptionFilter();
//    }

    /**
     * 动态路由
     * 采用sconfig动态刷新机制
     * */
    ///refresh
    @RefreshScope
    @ConfigurationProperties("zuul")
    public ZuulProperties zuulProperties(){
        return new ZuulProperties();
    }

}
